﻿using GrainManage.Data.Model;
using GrainManage.Data.Service.Util;
using System;
using System.Collections.Generic;
using System.Data;

namespace GrainManage.Data.Service
{
    public class TypeService : BaseService, GrainManage.Data.Service.Interfaces.ITypeService
    {
        public TypeService(GrainManage.Data.Access.IAccess proc) : base(proc) { }

        public List<string> GetNameByFlag(TypeFlag typeFlag, IPageable page, ICountable records)
        {
            var fieldList = new List<string>();
            DataSet ds = Proc.ExecuteQuery(ProcConst.Type_GetNameByFlag, (int)typeFlag, page.PageIndex, page.PageSize);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                if (item[0] != DBNull.Value)
                {
                    fieldList.Add(item[0] as string);
                }
            }

            if (records != null)
            {
                records.Total = GetTotalRowCount(ds);
            }

            return fieldList;
        }
    }
}
